<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.util.*,util.*,dal.*,model.*,bll.*"%>
<%
	ChecklistModel obj;
	Object temp = request.getAttribute("checklist");
	if (temp != null) {
		try {
			obj = (ChecklistModel) temp;
		} catch (Exception ex) {
			obj = new ChecklistModel();
		}
	} else {
		obj = new ChecklistModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Checklist</title>

<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css" type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" />

<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery-1.6.1.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.widget.min.js"></script>

<script language="javascript" type="text/javascript" src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxQuickInsert.js"></script>

<link rel="stylesheet" href="css/inputForm.css" />

<script language="javascript" type="text/javascript">
	//var requiredInputs = [['object_type','object_type_required'],['object_id','object_id_required'],['title','title_required'],['code','code_required'],['description','description_required'],['type','type_required'],['status','status_required'],['notification','notification_required'],['id_project','id_project_required'],['id_author','id_author_required'],['id_approver','id_approver_required']];
	var requiredInputs = [['object_type','object_type_required'],['object_id','object_id_required'],['title','title_required'],['code','code_required'],['description','description_required'],['id_project','id_project_required'],['id_author','id_author_required'],['id_approver','id_approver_required']];
	
	//var intInputs = [['type','type_invalid'],['status','status_invalid'],['notification','notification_invalid'],['id_project','id_project_invalid'],['id_author','id_author_invalid'],['id_approver','id_approver_invalid']];
	var intInputs = [['status','status_invalid'],['id_project','id_project_invalid'],['id_author','id_author_invalid'],['id_approver','id_approver_invalid']];
	var doubleInputs = [];
	var dateInputs = [];
	var timeInputs = [];
	
	function checkInputs() {
		var valid = true;
	
		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
// 		if (checkIntInputs(intInputs) == false) {
// 			valid = false;
// 		}
// 		if (checkDoubleInputs(doubleInputs) == false) {
// 			valid = false;
// 		}
// 		if (checkDateInputs(dateInputs) == false) {
// 			valid = false;
// 		}
// 		if (checkTimeInputs(timeInputs) == false) {
// 			valid = false;
// 		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
     <jsp:include page="menu.jsp"></jsp:include>
	<br />
    <table>
		<tr>
			<td>
	            <form action="checklist?mode=insert" method="post"
                    onSubmit="return checkInputs()"
                    onreset="return confirm('Do you really want to reset the form?')">
		            <table class="tblInput" border="1">
			            <tr class="inputHeader">
				            <th colspan="3" class="inputHeader">Create New Checklist</th>
			            </tr>
            			<tr class="trField">
				<td class="tdFieldName">Object Type</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="object_type" name="object_type" maxlength="50" value="<%=obj.getObjectTypeToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="object_type_required" class="errMsg" style="display: none;">Object Type is required</span>
					<span id="object_type_invalid" class="errMsg" style="display: none;">Object Type is invalid</span>
                    <span id="object_type_error" class="errMsg"><%=obj.errMsgs.ObjectType%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Object Id</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="object_id" name="object_id" maxlength="50" value="<%=obj.getObjectIdToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="object_id_required" class="errMsg" style="display: none;">Object Id is required</span>
					<span id="object_id_invalid" class="errMsg" style="display: none;">Object Id is invalid</span>
                    <span id="object_id_error" class="errMsg"><%=obj.errMsgs.ObjectId%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Title</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="title" name="title" maxlength="255" value="<%=obj.getTitleToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="title_required" class="errMsg" style="display: none;">Title is required</span>
					<span id="title_invalid" class="errMsg" style="display: none;">Title is invalid</span>
                    <span id="title_error" class="errMsg"><%=obj.errMsgs.Title%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Code</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="code" name="code" maxlength="20" value="<%=obj.getCodeToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="code_required" class="errMsg" style="display: none;">Code is required</span>
					<span id="code_invalid" class="errMsg" style="display: none;">Code is invalid</span>
                    <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Description</td>				    <td class="tdFieldInput">
					<textarea id="description" name="description" rows="5" class="inputTextarea"><%=obj.getDescriptionToString()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="description_required" class="errMsg" style="display: none;">Description is required</span>
					<span id="description_invalid" class="errMsg" style="display: none;">Description is invalid</span>
                    <span id="description_error" class="errMsg"><%=obj.errMsgs.Description%></span>
				</td></tr>
<!-- 			<tr class="trField"> -->
<!-- 				<td class="tdFieldName">Type</td>				<td class="tdFieldInput"> -->
<%-- 					<input class="inputInt" type="text" id="type" name="type" maxlength="10" value="<%=obj.getTypeToString()%>" /> --%>
<!-- 				</td> -->
<!-- 				<td class="tdErrMsg"> -->
<!-- 					<span id="type_required" class="errMsg" style="display: none;">Type is required</span>  -->
<!-- 					<span id="type_invalid" class="errMsg" style="display: none;">Type is invalid</span> -->
<%--                     <span id="type_error" class="errMsg"><%=obj.errMsgs.Type%></span> --%>
<!--                 </td></tr> -->
<!-- 			<tr class="trField"> -->
<!-- 				<td class="tdFieldName">Status</td>				<td class="tdFieldInput"> -->
<%-- 					<input class="inputInt" type="text" id="status" name="status" maxlength="10" value="<%=obj.getStatusToString()%>" /> --%>
<!-- 				</td> -->
<!-- 				<td class="tdErrMsg"> -->
<!-- 					<span id="status_required" class="errMsg" style="display: none;">Status is required</span>  -->
<!-- 					<span id="status_invalid" class="errMsg" style="display: none;">Status is invalid</span> -->
<%--                     <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span> --%>
<!--                 </td></tr> -->
<!-- 			<tr class="trField"> -->
<!-- 				<td class="tdFieldName">Is Draft</td><td class="tdFieldInput"> -->
<!-- 					<table class="tblBool"> -->
<!-- 						<tr class="trBoolSet"> -->
<!-- 							<td colspan="2" class="tdBoolSet"><input type="checkbox" -->
<!-- 								id="ckb_is_draft" name="ckb_is_draft" -->
<!-- 								onchange="toggleControls(['is_draft_true', 'is_draft_false'])" />Not -->
<!-- 								set</td> -->
<!-- 						</tr> -->
<!-- 						<tr class="trBool"> -->
<!-- 							<td class="tdBool"><input type="radio" -->
<!-- 								id="is_draft_true" name="is_draft" value="1" -->
<!-- 								checked="checked" />Yes</td> -->
<!-- 							<td class="tdBool"><input type="radio" -->
<!-- 								id="is_draft_false" name="is_draft" value="0" />No</td> -->
<!-- 						</tr> -->
<!-- 					</table></td> -->
<!-- 				<td class="tdErrMsg"></td></tr> -->
<!-- 			<tr class="trField"> -->
<!-- 				<td class="tdFieldName">Notification</td>				<td class="tdFieldInput"> -->
<%-- 					<input class="inputInt" type="text" id="notification" name="notification" maxlength="10" value="<%=obj.getNotificationToString()%>" /> --%>
<!-- 				</td> -->
<!-- 				<td class="tdErrMsg"> -->
<!-- 					<span id="notification_required" class="errMsg" style="display: none;">Notification is required</span>  -->
<!-- 					<span id="notification_invalid" class="errMsg" style="display: none;">Notification is invalid</span> -->
<%--                     <span id="notification_error" class="errMsg"><%=obj.errMsgs.Notification%></span> --%>
<!--                 </td></tr> -->
			<tr class="trField">
				<td class="tdFieldName">Id Project</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_project" name="id_project" maxlength="10" value="<%=obj.getIdProjectToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_project_required" class="errMsg" style="display: none;">Id Project is required</span> 
					<span id="id_project_invalid" class="errMsg" style="display: none;">Id Project is invalid</span>
                    <span id="id_project_error" class="errMsg"><%=obj.errMsgs.IdProject%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Author</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_author" name="id_author" maxlength="10" value="<%=obj.getIdAuthorToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_author_required" class="errMsg" style="display: none;">Id Author is required</span> 
					<span id="id_author_invalid" class="errMsg" style="display: none;">Id Author is invalid</span>
                    <span id="id_author_error" class="errMsg"><%=obj.errMsgs.IdAuthor%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Approver</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_approver" name="id_approver" maxlength="10" value="<%=obj.getIdApproverToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_approver_required" class="errMsg" style="display: none;">Id Approver is required</span> 
					<span id="id_approver_invalid" class="errMsg" style="display: none;">Id Approver is invalid</span>
                    <span id="id_approver_error" class="errMsg"><%=obj.errMsgs.IdApprover%></span>
                </td></tr>
			
			            <tr class="trInputBottom">
				            <td class="tdInputBottom" colspan="3">
					            <table class="tblSubmit" align="center">
						            <tr class="trSubmit">
							            <td class="tdSubmit"><input type="submit" value="Submit" />
							            </td>
							            <td class="tdReset"><input type="reset" value="Reset" /></td>
						            </tr>
					            </table></td>
			            </tr>
		            </table>
	            </form>
            </td>
		</tr>
	</table>
    <br />
	<jsp:include page="checklistList.jsp?embedded=true"></jsp:include>
</body>
</html>